package com.dyh.quickdemo.demos.grov;

import groovy.lang.GroovyClassLoader;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.stereotype.Component;

/*
@Author=Joey Wheeler
@Date=2021/1/7 11:07
*/
@SpringBootTest
public class CompForGrovTest {

    @Test
    public void test() throws IllegalAccessException, InstantiationException {
        String codeSrc = "package com.dyh.quickdemo.demos.grov;\n" +
                "\n" +
                "import org.slf4j.Logger;\n" +
                "import org.slf4j.LoggerFactory;\n" +
                "import org.springframework.beans.factory.annotation.Autowired;\n" +
                "\n" +
                "/*\n" +
                "@Author=Joey Wheeler\n" +
                "@Date=2021/1/7 11:16\n" +
                "*/\n" +
                "public class CallGrov {\n" +
                "//    @Autowired\n" +
                "//    CompForGrov compForGrov;\n" +
                "\n" +
                "        Logger logger = LoggerFactory.getLogger(this.getClass());\n" +
                "\n" +
                "    public void hello(){\n" +
                "        logger.info(\"CallGrov.hello\");\n" +
                "    }\n" +
                "}\n";
        GroovyClassLoader groovyClassLoader = new GroovyClassLoader();
        Class<?> clazz = groovyClassLoader.parseClass(codeSrc);
        Object instance = clazz.newInstance();

        System.out.println();

    }

//    @Autowired
//    CompForGrov compForGrov;
//
//    @Test
//    public void test(){
//        compForGrov.hello();
//    }


}
